package com.luoye.lj.util.date;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-11-2
 * Time: 下午4:10
 * To change this template use File | Settings | File Templates.
 */
public class DateParse {
    //转为时间
    public static Date toDate(String timeStr, String formatStr){
        SimpleDateFormat sdf=new SimpleDateFormat(formatStr);
        Date date=null;
        try {
            date=sdf.parse(timeStr);
        }catch (Exception ex){

        }
        return date;
    }
    public static Date toDate(String dateStr){
        Date date=toDate(dateStr,"yyyy-MM-dd");
        return date;
    }
    public static Date toTime(String timeStr){
        Date date=toDate(timeStr,"HH:mm:ss");
        return date;
    }
    public static Date toDateTime(String dateStr){
        Date date=toDate(dateStr,"yyyy-MM-dd HH:mm:ss");
        return date;
    }
}
